package com.bilicute.libman.config;

import com.bilicute.libman.interceptors.LoginInterceptors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @所属包名: com.bilicute.libman.config
 * @类名: WebConfig
 * @作者: i囡漫笔
 * @描述: WebConfig拦截器
 * @创建时间: 2024-06-19 08:43
 */


@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptors loginInterceptors;

    /**
     * @param registry:  [registry]
     * @author i囡漫笔
     * @description 拦截未登录请求
     * @date 2024/4/18
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登陆接口和注册接口不拦截
        registry.addInterceptor(loginInterceptors)
                .addPathPatterns("/firstController","/api/user/userInfo","/api/book/**","**/api/user/userInfo")
                .excludePathPatterns("/css/**","/js/**","/img/**","/api/info/**");
    }
}